export interface CodeAnalysisResult {
    suggestions: string[];
    improvements: {
        line: number;
        original: string;
        suggested: string;
        reason: string;
    }[];
    securityIssues: {
        severity: 'low' | 'medium' | 'high';
        description: string;
        location: {
            line: number;
            column: number;
        };
    }[];
}

export class CodeAnalysisFormatter {
    static formatForDisplay(result: CodeAnalysisResult): string {
        let output = '## 代码分析结果\n\n';
        
        if (result.suggestions.length > 0) {
            output += '### 总体建议\n';
            result.suggestions.forEach(suggestion => {
                output += `- ${suggestion}\n`;
            });
        }

        if (result.improvements.length > 0) {
            output += '\n### 具体改进\n';
            result.improvements.forEach(imp => {
                output += `- 第 ${imp.line} 行:\n`;
                output += `  原代码: ${imp.original}\n`;
                output += `  建议: ${imp.suggested}\n`;
                output += `  原因: ${imp.reason}\n\n`;
            });
        }

        if (result.securityIssues.length > 0) {
            output += '\n### 安全问题\n';
            result.securityIssues.forEach(issue => {
                output += `- [${issue.severity.toUpperCase()}] ${issue.description}\n`;
                output += `  位置: 第 ${issue.location.line} 行, 第 ${issue.location.column} 列\n`;
            });
        }

        return output;
    }
} 